cmake_minimum_required(VERSION 3.8)
project(bag_tools_cpp)

# Default to C++17
if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 17)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(std_msgs REQUIRED)
find_package(cv_bridge REQUIRED)
find_package(image_transport REQUIRED)
set(ROS_LIBS
        rclcpp sensor_msgs  std_msgs
        cv_bridge  image_transport
        )

find_package(OpenCV REQUIRED)

include_directories(
        include
        ${OpenCV_INCLUDE_DIRS}
)


# add the publisher example
add_executable(my_publisher src/my_publisher.cpp)
ament_target_dependencies(my_publisher ${ROS_LIBS})
target_link_libraries(my_publisher ${OpenCV_LIBS})

# add the subscriber example
add_executable(my_subscriber src/my_subscriber.cpp)
ament_target_dependencies(my_subscriber ${ROS_LIBS})
target_link_libraries(my_subscriber ${OpenCV_LIBS})


add_executable(compress_kitti src/compress_kitti.cpp src/image_node.cpp)
ament_target_dependencies(compress_kitti ${ROS_LIBS})
target_link_libraries(compress_kitti ${OpenCV_LIBS})


install(TARGETS
        my_publisher
        my_subscriber
        compress_kitti
        DESTINATION lib/${PROJECT_NAME})

# install(DIRECTORY
#         launch
#         DESTINATION share/${PROJECT_NAME}/
#         )

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  # the following line skips the linter which checks for copyrights
  # uncomment the line when a copyright and license is not present in all source files
  #set(ament_cmake_copyright_FOUND TRUE)
  # the following line skips cpplint (only works in a git repo)
  # uncomment the line when this package is not in a git repo
  #set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_dependencies()
endif()

ament_package()
